//
//  YTVideoPlayerController.m
//  YUNT
//
//  Created by haha on 2017/11/26.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTVideoPlayerController.h"
#import "YTPhotoLibraryManager.h"
#import "ZFPlayer/ZFPlayer.h"

@interface YTVideoPlayerController ()<ZFPlayerDelegate>

@property (nonatomic, strong) ZFPlayerView *playerView;

@end

@implementation YTVideoPlayerController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blackColor];
    
    NSString *videoPath = [kVideoPath stringByAppendingString:self.resoucesItem.resourceName];
    
    NSURL *movieUrl = [NSURL fileURLWithPath:videoPath];
    
    self.playerView = [[ZFPlayerView alloc] init];
    [self.view addSubview:self.playerView];
    [self.playerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(20);
        make.left.right.equalTo(self.view);
        // Here a 16:9 aspect ratio, can customize the video aspect ratio
        make.height.equalTo(self.playerView.mas_width).multipliedBy(9.0f/16.0f);
    }];
    // control view（you can custom）
    ZFPlayerControlView *controlView = [[ZFPlayerControlView alloc] init];
    // model
    ZFPlayerModel *playerModel = [[ZFPlayerModel alloc]init];
    playerModel.fatherView = self.view;
    playerModel.videoURL = movieUrl;
    playerModel.title = Language(self.resoucesItem.resourceName);
    [self.playerView playerControlView:controlView playerModel:playerModel];

    // delegate
    self.playerView.delegate = self;
    // auto play the video
    [self.playerView autoPlayTheVideo];
    
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/** backBtn event */
- (void)zf_playerBackAction
{
    
}
/** downloadBtn event */
- (void)zf_playerDownload:(NSString *)url
{
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
